package com.example.service;

import com.example.pojo.entity.PostDocument;
import com.example.rbm.PostDocumentIndex;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.SearchHits;
import org.springframework.stereotype.Service;
import org.springframework.transaction.support.TransactionTemplate;

/**
 * @author 小岁
 * @version 2023/10/24 19:07
 */
@Slf4j
@Service
public class PostDocumentService {
    @Autowired
    private PostDocumentIndex postDocumentIndex;
    @Autowired
    private TransactionTemplate transactionTemplate;

    @Autowired
    private ElasticsearchTemplate elasticsearchTemplate;

    public PostDocumentService(PostDocumentIndex postDocumentIndex,
                               TransactionTemplate transactionTemplate){
        this.postDocumentIndex=postDocumentIndex;
        this.transactionTemplate=transactionTemplate;
    }
    public SearchHits<PostDocument> searchPostDocument(String keyword){
        return postDocumentIndex.find(keyword);
    }

}
